************Table 1***********
tab outcome if hvaccred==0
tab outcome if hvaccred==1
ttest outcome, by(hvaccred)

tab outcome if crimrec==0
tab outcome if crimrec==1
ttest outcome, by(crimrec)

tab outcome if white==0
tab outcome if white==1
ttest outcome, by(white)
tab outcome 

************Table 2***********
***Model 1***
melogit outcome i.hvaccred i.crimrec i.white || id:, or
melogit outcome i.hvaccred i.crimrec i.white || id:
est sto ME1

***Model 2***
melogit outcome i.hvaccred i.crimrec i.white i.state i.month i.jobtitle i.references i.order|| id:, or
melogit outcome i.hvaccred i.crimrec i.white i.state i.month i.jobtitle i.references  i.order || id:
est sto ME2
lrtest ME1 ME2, stats
pwcompare month, eff
*hypotheses 1, 2, and 4*
margins, dydx(hvaccred crimrec white)
*Figure 3*
margins i.hvaccred#i.crimrec#i.white
marginsplot, recast(bar) xdimension(hvaccred crimrec) by(white) ///
    ytitle("Pr(Callback)") ///
    xlabel(,angle(0)) ///
    plotopts(barwidth(0.5)) ///
    graphregion(color(white))
margins i.hvaccred#i.crimrec#i.white, pwcompare(effects)

***Model 3***
melogit outcome i.hvaccred##i.crimrec i.white i.state i.month i.jobtitle i.references i.order|| id:, or
melogit outcome i.hvaccred##i.crimrec i.white i.state i.month i.jobtitle i.references i.order|| id:
est sto ME3
lrtest ME2 ME3, stats
testparm i.hvaccred#i.crimrec
*hypothesis 3*
margins i.hvaccred#i.crimrec, contrast(effects)
margins, dydx(hvaccred) over(crimrec) pwcompare(effects)
*Figure 1*
margins, dydx(hvaccred) over(crimrec)
marginsplot, recast(bar) ///
    yline(0) ///
    plotopts(barwidth(0.5)) ///
	graphregion(color(white))

***Model 4***
melogit outcome i.hvaccred##i.crimrec##i.white i.state i.month i.jobtitle i.references i.order || id:, or
melogit outcome  i.hvaccred##i.crimrec##i.white i.state i.month i.jobtitle i.references i.order || id:
est sto ME4
lrtest ME2 ME4, stats
testparm i.hvaccred#i.crimrec#i.white
*hypothesis 5*
margins i.hvaccred#i.white, at(crimrec=(1)) contrast(effects)
margins, dydx(hvaccred) over(white) at(crimrec=(1)) pwcompare(effects)
*Figure 2*
margins, dydx(hvaccred) over(white) at(crimrec=(1))
marginsplot, recast(bar) ///
    xlabel(0 "Black" 1 "White", noticks) ///
    yline(0) ///
    plotopts(barwidth(0.5) ///
    graphregion(color(white)))

esttab ME1 ME2 ME3 ME4 using "Table 2.rtf", b(3) se(3) star compress nogaps label nobase replace

************Appendix B***********
***Model 5***
melogit outcome i.hvaccred##i.month i.crimrec##i.month i.white##i.month i.state i.jobtitle i.references i.order|| id:
melogit outcome i.hvaccred##i.month i.crimrec##i.month i.white##i.month i.state i.jobtitle i.references i.order|| id:, or
est sto ME5
lrtest ME2 ME5, stats
testparm i.hvaccred#i.month
testparm i.crimrec#i.month
testparm i.white#i.month
*hypotheses 1, 2, 4 by month*
margins, dydx(hvaccred crimrec white) over(month) pwcompare(effects)
*Figure B.2*
margins, dydx(hvaccred crimrec white) over(month) 
marginsplot, recast(bar) by(month) ///
   xlabel(,angle(45)) ///
   plotopts(barwidth(0.6)) ///
   graphregion(color(white)) ///
   yline(0)

***Model 6***
melogit outcome i.hvaccred##i.crimrec##i.month i.white i.state i.jobtitle i.references i.order|| id:
melogit outcome i.hvaccred##i.crimrec##i.month i.white i.state i.jobtitle i.references i.order|| id:, or
est sto ME6
lrtest ME2 ME6, stats
testparm i.hvaccred#i.crimrec#i.month
*hypothesis 3 by month*
margins, dydx(hvaccred) over(crimrec month) pwcompare(effects)
*Figure B.3*
margins, dydx(hvaccred) over(crimrec month)
marginsplot, recast(bar) x(crimrec) by(month) ///
    xlabel(,angle(45)) ///
	plotopts(barwidth(0.6)) ///
    graphregion(color(white)) ///
    yline(0)

***Model 7***
melogit outcome i.hvaccred##i.crimrec##i.white##i.month  i.state i.jobtitle i.references i.order|| id:
melogit outcome i.hvaccred##i.crimrec##i.white##i.month i.state i.jobtitle i.references i.order|| id:, or
est sto ME7
lrtest ME2 ME7, stats
testparm i.hvaccred#i.crimrec#i.white#i.month
*hypothesis 5 by month*
margins, dydx(hvaccred) over(white month) at(crimrec=(1)) pwcompare(effects)
*Figure B.4*
margins, dydx(hvaccred) over(white month) at(crimrec=(1))
marginsplot, recast(bar) by(month) ///
    xlabel(,angle(45)) ///
	plotopts(barwidth(0.6)) ///
    graphregion(color(white)) ///
    yline(0)
